#if  (FEATURE_MODE == 0)
/**
 @file ctc_tmx_pon.c

 @author  Copyright (C) 2011 Centec Networks Inc.  All rights reserved.

 @date 2020-12-18

 @version v1.0

 The file provide all pon related APIs.
*/

/****************************************************************************
 *
* Header Files
*
****************************************************************************/
#include "ctc_error.h"
#include "ctc_debug.h"

#include "ctc_tmx_pon.h"
#include "sys_usw_pon.h"
#include "sys_usw_common.h"
/****************************************************************************
 *
* Defines and Macros
*
*****************************************************************************/

/****************************************************************************
 *
* Global and Declaration
*
*****************************************************************************/
/****************************************************************************
 *
* Function
*
*****************************************************************************/


/*Gem Port*/
int32
ctc_tmx_pon_create_gem_port(uint8 lchip, ctc_pon_gem_port_t* p_gem_port)
{
    FEATURE_SUPPORT_CHECK(CTC_FEATURE_PON);
    LCHIP_CHECK(lchip);
    CTC_PTR_VALID_CHECK(p_gem_port);
    CTC_ERROR_RETURN(sys_usw_pon_create_gem_port(lchip, p_gem_port));

    return CTC_E_NONE;
}

int32
ctc_tmx_pon_destroy_gem_port(uint8 lchip, ctc_pon_gem_port_t* p_gem_port)
{
    FEATURE_SUPPORT_CHECK(CTC_FEATURE_PON);
    LCHIP_CHECK(lchip);
    CTC_PTR_VALID_CHECK(p_gem_port);
    CTC_ERROR_RETURN(sys_usw_pon_destroy_gem_port(lchip, p_gem_port));

    return CTC_E_NONE;
}

int32
ctc_tmx_pon_update_gem_port(uint8 lchip, ctc_pon_gem_port_t* p_gem_port)
{
    FEATURE_SUPPORT_CHECK(CTC_FEATURE_PON);
    LCHIP_CHECK(lchip);
    CTC_PTR_VALID_CHECK(p_gem_port);
    CTC_ERROR_RETURN(sys_usw_pon_update_gem_port(lchip, p_gem_port));

    return CTC_E_NONE;
}

int32
ctc_tmx_pon_get_gem_port(uint8 lchip, ctc_pon_gem_port_t* p_gem_port)
{
    FEATURE_SUPPORT_CHECK(CTC_FEATURE_PON);
    LCHIP_CHECK(lchip);
    CTC_PTR_VALID_CHECK(p_gem_port);
    CTC_ERROR_RETURN(sys_usw_pon_get_gem_port(lchip, p_gem_port));

    return CTC_E_NONE;
}


/*Vlan Port*/
int32
ctc_tmx_pon_create_vlan_port(uint8 lchip, ctc_pon_vlan_port_t* p_vlan_port)
{
    FEATURE_SUPPORT_CHECK(CTC_FEATURE_PON);
    LCHIP_CHECK(lchip);
    CTC_PTR_VALID_CHECK(p_vlan_port);
    SYS_MAP_GPORT_TO_LCHIP(p_vlan_port->gport, lchip);
    CTC_ERROR_RETURN(sys_usw_pon_create_vlan_port(lchip, p_vlan_port));

    return CTC_E_NONE;
}

int32
ctc_tmx_pon_destroy_vlan_port(uint8 lchip, ctc_pon_vlan_port_t* p_vlan_port)
{
    FEATURE_SUPPORT_CHECK(CTC_FEATURE_PON);
    LCHIP_CHECK(lchip);
    CTC_PTR_VALID_CHECK(p_vlan_port);
    SYS_MAP_GPORT_TO_LCHIP(p_vlan_port->gport, lchip);
    CTC_ERROR_RETURN(sys_usw_pon_destroy_vlan_port(lchip, p_vlan_port));

    return CTC_E_NONE;
}

int32
ctc_tmx_pon_update_vlan_port(uint8 lchip, ctc_pon_vlan_port_t* p_vlan_port)
{
    FEATURE_SUPPORT_CHECK(CTC_FEATURE_PON);
    LCHIP_CHECK(lchip);
    CTC_PTR_VALID_CHECK(p_vlan_port);
    SYS_MAP_GPORT_TO_LCHIP(p_vlan_port->gport, lchip);
    CTC_ERROR_RETURN(sys_usw_pon_update_vlan_port(lchip, p_vlan_port));

    return CTC_E_NONE;
}

int32
ctc_tmx_pon_get_vlan_port(uint8 lchip, ctc_pon_vlan_port_t* p_vlan_port)
{
    FEATURE_SUPPORT_CHECK(CTC_FEATURE_PON);
    LCHIP_CHECK(lchip);
    CTC_PTR_VALID_CHECK(p_vlan_port);
    SYS_MAP_GPORT_TO_LCHIP(p_vlan_port->gport, lchip);
    CTC_ERROR_RETURN(sys_usw_pon_get_vlan_port(lchip, p_vlan_port));

    return CTC_E_NONE;
}


/*Network port*/
int32
ctc_tmx_pon_set_port_propery(uint8 lchip, uint32 gport, ctc_pon_port_cfg_t* cfg)
{
    FEATURE_SUPPORT_CHECK(CTC_FEATURE_PON);
    LCHIP_CHECK(lchip);
    SYS_MAP_GPORT_TO_LCHIP(gport, lchip);
    CTC_ERROR_RETURN(sys_usw_pon_set_port_propery(lchip, gport, cfg));

    return CTC_E_NONE;
}

int32
ctc_tmx_pon_get_port_propery(uint8 lchip, uint32 gport, ctc_pon_port_cfg_t* cfg)
{
    FEATURE_SUPPORT_CHECK(CTC_FEATURE_PON);
    LCHIP_CHECK(lchip);
    SYS_MAP_GPORT_TO_LCHIP(gport, lchip);
    CTC_ERROR_RETURN(sys_usw_pon_get_port_propery(lchip, gport, cfg));

    return CTC_E_NONE;
}


/*Init*/
int32
ctc_tmx_pon_init(uint8 lchip, void* pon_gblobal_cfg)
{
    uint8 lchip_start              = 0;
    uint8 lchip_end                = 0;
    ctc_pon_global_cfg_t global_cfg;


    LCHIP_CHECK(lchip);

    if (NULL == pon_gblobal_cfg)
    {
        sal_memset(&global_cfg, 0, sizeof(ctc_pon_global_cfg_t));
    }
    else
    {
        sal_memcpy(&global_cfg, pon_gblobal_cfg, sizeof(ctc_pon_global_cfg_t));
    }

    CTC_FOREACH_LCHIP(lchip_start, lchip_end, 1)
    {
        CTC_ERROR_RETURN(sys_usw_pon_init(lchip, &global_cfg));
    }

    return CTC_E_NONE;
}
int32
ctc_tmx_pon_deinit(uint8 lchip, void* pon_gblobal_cfg)
{
    uint8 lchip_start              = 0;
    uint8 lchip_end                = 0;

    LCHIP_CHECK(lchip);

    CTC_FOREACH_LCHIP(lchip_start, lchip_end, 1)
    {
        CTC_ERROR_RETURN(sys_usw_pon_deinit(lchip, pon_gblobal_cfg));
    }

    return CTC_E_NONE;
}
#endif

